<?php
require_once($_SERVER['DOCUMENT_ROOT']."/defaultconf.mex");
require_once($GLOBALS['PAD']."Modules/FTK9D4D0/modconf.mex");
MYTCONN(); 

	$qr_String = '';
	
	if ($_POST['OFCountry'] > 0) {
	$qr_String .= ' AND bp_Country = '.$_POST['OFCountry'];
	}
	
	$GET = $GLOBALS['MYT']->db_array("SELECT 
						bp_ID			AS COLID,
						bp_IdBanco		AS COL1,
						bp_Name			AS COL2,
						pai_NombreUSD	AS COL3,
						bp_Flag	AS COL4	
				 FROM hd_bancos
						INNER JOIN hd_paises ON pai_CodElite = bp_Country
					WHERE bp_Flag IN (1,2) {$qr_String}");
	$CCOL = $GET[0];
					?>
<script charset="utf-8" type="text/javascript">
disableSelection(document.getElementById("CFBK_Results"))

Ext.onReady(function(){

    Ext.QuickTips.init();

    var myData = [
	<?php   
	for ($i=1;$i<=$CCOL;$i++) { 
	echo "[{$i},'{$GET[$i]['COLID']}','{$GET[$i]['COL1']}','{$GET[$i]['COL2']}','{$GET[$i]['COL3']}','{$GET[$i]['COL4']}']";
		if ($i<$CCOL) {
			echo ',';
		}
    } ?>
    ];

    var ds = new Ext.data.Store({
        reader: new Ext.data.ArrayReader({}, [
               {name: 'id'},
			   {name: 'COLID', type: 'int'},
               {name: 'COL1', type: 'string'},
               {name: 'COL2', type: 'string'},
               {name: 'COL3', type: 'string'},
			   {name: 'COL4', type: 'string'}
          ])
    });
    ds.loadData(myData);
    var colModel = new Ext.grid.ColumnModel([
        {header: "Numero", width: 75, sortable: true, locked:true, dataIndex: 'COLID'},
        {header: "Registo Nacional", width: 80, sortable: true, locked:true, dataIndex: 'COL1'},
        {header: "Designacao", width: 300, sortable: true, dataIndex: 'COL2'},
        {header: "Pais", width: 120, sortable: true, locked:true, dataIndex: 'COL3'},
        {header: "Estado", width: 75, sortable: true, locked:true, dataIndex: 'COL4'}
    ]);

   var selmode = new Ext.grid.RowSelectionModel({});
   var Console = new Ext.grid.GridPanel({
	    title: 'Entidades Bancarias Configuradas',
		layout:'fit',
		ds: ds,
	    cm: colModel,
	    sm: selmode,
		listeners: {
	 				rowdblclick: function(ds, row) { 
					var record = ds.getStore().getAt(row);
  					var value = record.get('COLID');	
					modalwindow('Propriedades do Banco','<?php echo $MODURL;?>Lib/frm_a04CFBK.php?CFBK='+value,800,500);
					}
				},
	    height: 440,
        renderTo: 'CFBK_Results'
    });
		
});
</script>